package com.search.commons;

import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.IOException;

/**
 * Created by Tonight on 2017/4/5.
 *
 * 数据检索公共模块
 */
public class SearchCore {

    public static Document getHtmlDom(String url)
    {
        Document document = null;

        try {
            Connection connection = Jsoup.connect(url);

            //添加chrome 浏览器标识
            connection.userAgent("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36");

            //设置网络访问超时时间
            connection.timeout(3000);

            //网络获取网页
            document = connection.get();

        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return document;
    }
}
